home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / oxcc1434.zip / DOC / ANF.TXT next >
Text File  |  1995-09-09  |  3KB  |  69 lines

  1. ANF.TXT -- preliminary 15 May 1995 by Norman D. Culver
  2.  
  3.     Architecture Neutral Format (ANF) code is generated by `oxcc' and
  4.     placed in files with a .anf suffix. The purpose of ANF code is to
  5.     allow multiple back ends to be written by users. A sample back end
  6.     is `oxccb' which converts .anf to .byt for interpretation by the
  7.     sample interpreter `bterp'.
  8.  
  9.     The .anf format is given precisely in the files `oxanf.h' and `oxccb.c'.
  10.     Files are always generated in little endian format.
  11.  
  12.     Each ANF instruction is 8 bytes of required info plus an optional
  13.     number of additional bytes depending upon whether the opcode uses
  14.     0,1,2 or 3 address format.
  15.  
  16.     The programmer can view .anf code in human readable format by using
  17.     the -Gd option in `oxcc' which will produce a readable file with
  18.     a .dbg suffix.
  19.  
  20.     Byte     Meaning                      Format
  21.     0        opcode                       cccccccc       0-255
  22.     1        non zero if D address used   tttsssss       0-7|0-31
  23.     2        non zero if L address used   tttsssss       0-7|0-31
  24.     3        non zero if R address used   tttsssss       0-7|0-31
  25.     4        unsigned size of anf instruction
  26.     5-7      always zero in file, used for linking by backends
  27.     8-n      optional address elements D,L,R (no holes)
  28.  
  29.     Where:
  30.        c is the opcode
  31.        t is the type of the address element
  32.        s is the size of the address element
  33.  
  34.     Address element types:
  35.        0 == OPIMMED1   immediate signed value(s)
  36.        1 == OPIMMED2   immediate unsigned value(s)
  37.        2 == OPIMMED3   immediate floating value
  38.        3 == OPIMMED4   immediate pointer value
  39.        4 == OPTEMP     temp designator
  40.        5 == OPRET      return designator
  41.        6 == OPAUTO     autovar address
  42.        7 == OPDATA     data address
  43.  
  44.  
  45. HEADER
  46.     Each ANF section in a file is preceeded by a header consisting of 24
  47.     bytes in the following format:
  48.  
  49.     0xa5,0x30,0,0,0,0,0,0        // headerop,OPIMMED2|16,0,0,0,0,0,0
  50.     struct _hdr { /* see oxanf.h */
  51.         unsigned short major;
  52.         unsigned short minor;
  53.         char code_format;
  54.         char target_hardware;
  55.         char target_debugger;
  56.         char target_os;
  57.         char memory_model;
  58.         char obj_format;
  59.         char opt_level;
  60.         char target_assembler;
  61.         char pads[4];
  62.     };
  63.  
  64. TRAILER
  65.     A file is terminated with a trailer consisting
  66.     of 8 bytes in the following format:
  67.     
  68.     0xc4,0,0,0,0,0,0,0            // endallop,0,0,0,0,0,0,0
  69.